var seletetreatmentUnitValue = $('#treatmentUnitValue').val();
if (seletetreatmentUnitValue != "") {
    $("#treatmentUnit option[value='" + seletetreatmentUnitValue + "']").attr("selected", "selected")
}
var seletefieldTc = $('#queryTcValue').val();
if (seletefieldTc != "") {
    $("#fieldTc option[value='" + seletefieldTc + "']").attr("selected", "selected")
}
addTcCustomerCZ = function () {
    var fieldTc = document.getElementById("fieldTc").value;
    var reservationsId = document.getElementById("reservationsId").value;
    var treatmentUnit = document.getElementById("treatmentUnit").value;
    var customerName = document.getElementById("customerName").value;
    var remarks = document.getElementById("remarks").value;
    var seletetreatmentUnitValue = $('#treatmentUnitValue').val();
    var seletefieldTc = $('#fieldTcValue').val();
    if (treatmentUnit == null || treatmentUnit == "") {
        alert("请选择科室！");
        return
    }
    if (fieldTc == null || fieldTc == "") {
        alert("请选择TC！");
        return
    }
    if (fieldTc != seletefieldTc || treatmentUnit != seletetreatmentUnitValue) {
        if (remarks == null || remarks == "") {
            alert("请填写备注！");
            return
        }
    }
    $.ajax({
        url: Feng.ctxPath + "/customer/addNatureCustomerCZ",
        type: "post",
        data: {
            "reservationsId": reservationsId,
            "customerName": customerName,
            "treatmentUnit": treatmentUnit,
            "fieldTc": fieldTc,
            "remarks": remarks
        },
        success: function (data) {
            var ids=data.ids;
            if (ids == 0) {
                alert("该科室已存在不需要重咨！");
                return
            } else if (ids == 2) {
                alert("该患者今天已经分配过tc，不需要重咨！");
                return
            } else {
                if(data.status==1){
                    window.parent.register(data);
                }
                Feng.success('添加成功!');
                window.parent.Consultant.search();
                parent.layer.close(parent.layer.getFrameIndex(window.name))
            }
        },
        error: function (data) {
            alert('没有权限，请联系系统管理员!');
            parent.layer.close(parent.layer.getFrameIndex(window.name))
        }
    })
};